package com.leo;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.cutscene.Cutscene;
import com.almasb.fxgl.dsl.FXGL;
import com.leo.entity.ChatEntityFactory;
import javafx.util.Duration;

import java.util.List;

/**
 * @Author: wangss
 * @CreateTime: 2023-05-31  23:32
 * @Description: 过场动画
 */
public class ChatApp extends GameApplication {
    @Override
    protected void initSettings(GameSettings settings) {
        settings.setWidth(1024);
        settings.setHeight(608);
        settings.setTitle("聊天对话");
        // 开启性能监视器
        settings.setProfilingEnabled(true);
    }

    @Override
    protected void initGame() {
        FXGL.getGameWorld().addEntityFactory(new ChatEntityFactory());
        FXGL.spawn("bg");
        FXGL.runOnce(() -> {
            List<String> lines = FXGL.getAssetLoader().loadText("chat.txt");
            Cutscene cutscene = new Cutscene(lines);
            FXGL.getCutsceneService().startCutscene(cutscene);
        }, Duration.seconds(1));
    }

    public static void main(String[] args) {
        launch(args);
    }
}
